package com.lagou.cl.service.impl;

import com.lagou.cl.dao.COrderDao;
import com.lagou.cl.pojo.COrder;
import com.lagou.cl.service.COrderService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class COrderServiceImpl implements COrderService {


	private final COrderDao cOrderDao;

	public COrderServiceImpl(COrderDao cOrderDao) {
		this.cOrderDao = cOrderDao;
	}

	@Override
	public void addCOrder(COrder cOrder) {
		cOrderDao.save(cOrder);
	}

	@Override
	public List<COrder> findByUserId(Integer userId) {
		List<COrder> orders = cOrderDao.findCOrdersByUserId(userId);
		return orders;
	}

	@Override
	public List<COrder> findAll() {
		return cOrderDao.findAll();
	}
}
